﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace deFramework.Common
{
    public class EncryptionTools
    {





        /// <summary>
        /// Uses the built-in .NET functionality for the HMACSHA1 encryption protocol
        /// to generate an output hash result string.
        /// </summary>
        /// <param name="inputValue">input value string used to generate hash result string</param>
        /// <param name="hashKey">key used to generate hash result string</param>
        /// <returns>output hash result string</returns>
        public string HMACSHA1Output(string inputValue, string hashKey)
        {
            byte[] bytesKey = System.Text.Encoding.ASCII.GetBytes(hashKey);
            byte[] bytesValue = System.Text.Encoding.ASCII.GetBytes(inputValue);
            System.Security.Cryptography.HMACSHA1 encryptObject =
                new System.Security.Cryptography.HMACSHA1();
            encryptObject.Key = bytesKey;
            byte[] bytesHashMessage = encryptObject.ComputeHash(bytesValue);
            return Convert.ToBase64String(bytesHashMessage);
        } 




    }
}
